package fr.afcepf.atod12.afcepfvoyage.dao.generic;

import java.io.Serializable;
import java.util.Collection;

import javax.persistence.EntityManager;
import javax.persistence.Query;

public abstract class AbstractGenericDaoJpaImpl<T> implements IGenericDao<T> {
	
	protected EntityManager entityManager;
	
	public T getEntityById(Class<T> c,Long id) {
		return entityManager.find(c, id);			
	}

	@SuppressWarnings("unchecked")
	public Collection<T> getEntitys(Class<T> c, String ent) {
		Query query = entityManager.createQuery("FROM "+ent+" entity", c);		
		return (Collection<T>) query.getResultList();										
	}
	
	@Override
	public T updateEntity(T e) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void deleteEntity(Class<T> c, Serializable pk) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removeEntity(Object e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public T persistNewEntity(T e) {
		// TODO Auto-generated method stub
		return null;
	}

	
}
